home *** CD-ROM | disk | FTP | other *** search
- if(typeof cpvw_siteManager=="undefined"){
- var cpvw_siteManager={arrSiteList:null,siteDom:null,xmlSiteFile:"CoolirisPreviewSites.xml",isCustomSite:function(_1){
- var _2=[false,""];
- _2=this.isIncludedSite(_1);
- return _2;
- },isIncludedSite:function(_3){
- var _4=[false,""];
- if(this.siteDom==null){
- this.loadSites();
- }
- if(this.siteDom!=null){
- try{
- var _5=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
- _5.spec=_3;
- }
- catch(ex){
- return [false,""];
- }
- var _6;
- var _7;
- if(_5.host!=null){
- _7=escape(_5.host);
- _6=this.getResultFromXPath("//SITE-URL[@DOMAIN='"+_7+"']",this.siteDom);
- }
- if(_6!=null){
- if(_6.snapshotLength==1){
- if(_6.snapshotItem(0).getAttribute("ENABLED")=="yes"){
- _4=[true,this.isPreferredSite(_3)];
- }else{
- _4=[false,""];
- }
- }else{
- if(_6.snapshotLength==0){
- var _8=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewDefaultEnable);
- if(_8=="yes"){
- _4=[true,this.isPreferredSite(_3)];
- }else{
- _4=[false,""];
- }
- }
- }
- }
- }
- return _4;
- },isPreferredSite:function(_9){
- conDump("is prefererfd fdf site "+_9+", "+_9.match(/^http:\/\/\w{3}.google.[a-z.]+\/#/i));
- if(_9.match(/^http:\/\/\w{3}.google.[a-z.]+\/webhp/i)||_9.match(/^http:\/\/\w{3}.google.[a-z.]+\/search/i)||_9.match(/^http:\/\/\w{3}.google.[a-z.]+\/custom/i)||_9.match(/^http:\/\/\w{3}.google.[a-z.]+\/#/i)){
- return "google_search";
- }
- if(_9.match(/^http:\/\/[a-z.]+ebay.[a-z.]+/i)){
- return "ebay";
- }
- if(_9.match(/^http:\/\/w{3}.tagworld.[a-z.]+/i)){
- return "tagworld";
- }
- if(_9.match(/^http:\/\/[a-z.]+craigslist.[a-z.]+/i)){
- return "craigslist";
- }
- if(_9.match(/^http:\/\/[a-z.]+myspace.[a-z.]+/i)){
- return "myspace";
- }
- if(_9.match(/^http:\/\/[a-z.]+cooliris.[a-z.]+/i)){
- return "cooliris";
- }
- if(_9.match(/^http:\/\/[a-z.]+rediff.[a-z.]+/i)){
- return "rediff";
- }
- if(_9.match(/^http:\/\/video.google.[a-z.]+/i)){
- return "google_video";
- }
- if(_9.match(/^http:\/\/w{3}.gravee.[a-z.]+\/search/i)){
- return "gravee";
- }
- if(_9.match(/^http:\/\/w{3}.technorati.[a-z.]+\/search/i)){
- return "technorati";
- }
- if(_9.match(/^http:\/\/news.google.[a-z.]+\//i)){
- return "google_news";
- }
- if(_9.match(/^http:\/\/scholar.google.[a-z.]+\/scholar/i)){
- return "google_scholar";
- }
- if(_9.match(/^http:\/\/del.icio.us/i)){
- return "delicious";
- }
- if(_9.match(/^http:\/\/search.yahoo.[a-z.]+\/search/i)){
- return "yahoo_search";
- }
- if(_9.match(/^http:\/\/www.newsvine.[a-z.]+/i)){
- return "newsvine";
- }
- if(_9.match(/^http:\/\/www.youtube.[a-z.]+/i)||_9.match(/^http:\/\/youtube.[a-z.]+/i)){
- return "youtube_video";
- }
- if(_9.match(/^http:\/\/images.google.[a-z.]+\/images/i)){
- return "google_images";
- }else{
- if(_9.match(/^http:\/\/images.search.yahoo.[a-z.]+\/search\/images/i)){
- return "yahoo_images";
- }else{
- return "general";
- }
- }
- },loadSites:function(){
- try{
- var _a=cpvw_jsUtils.getWorkingFolder();
- _a.append(this.xmlSiteFile);
- var _b;
- if(!_a.exists()){
- _b="chrome://cooliris/content/CoolirisPreviewSitesTemplate.xml";
- }else{
- _b="file:///"+_a.path;
- }
- var _c=new XMLHttpRequest();
- _c.open("GET",_b,false);
- _c.send(null);
- this.siteDom=_c.responseXML;
- if(this.siteDom.documentElement.nodeName=="parsererror"){
- throw "Error retrieving site list";
- }
- }
- catch(ex){
- alert(ex);
- }
- },editSite:function(_d,_e){
- var _f=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
- _f.spec=_d;
- var _10,_11;
- if(_f.host!=null){
- _11=escape(_f.host);
- _10=this.getResultFromXPath("//SITE-URL[@DOMAIN='"+_11+"']",this.siteDom);
- }
- if(_10!=null){
- if(_10.snapshotLength==0){
- var _12=this.siteDom.createElement("SITE-URL");
- _12.setAttribute("ENABLED",_e);
- _12.setAttribute("TYPE","domain");
- _12.setAttribute("DOMAIN",_11);
- _12.appendChild(this.siteDom.createCDATASection(_d));
- this.siteDom.firstChild.appendChild(_12);
- }else{
- _10.snapshotItem(0).setAttribute("ENABLED",_e);
- }
- this.saveSite();
- }
- },saveSite:function(){
- try{
- var _13=new XMLSerializer();
- var _14=Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
- var _15=cpvw_jsUtils.getWorkingFolder();
- _15.append(this.xmlSiteFile);
- _14.init(_15,2|8|32,436,0);
- _13.serializeToStream(this.siteDom,_14,"");
- _14.close();
- return true;
- }
- catch(ex){
- alert(ex);
- return false;
- }
- },getResultFromXPath:function(_16,_17){
- try{
- var _18=XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
- var _19=document.createNSResolver(_17.ownerDocument==null?_17.documentElement:_17.ownerDocument.documentElement);
- var _1a=_17.evaluate(_16,_17,_19,_18,null);
- }
- catch(ex){
- return null;
- }
- return _1a;
- }};
- }
-
-